SDK_LIB_PATH := -L$(REL_LIB) -L$(REL_LIB)/extdrv

SDK_LIB := $(SDK_LIB_PATH) --start-group -lsys_config -lhi_osal -lmpi -l$(ARCH_LIBNAME)_base -l$(ARCH_LIBNAME)_sys -lhi_user -l$(ARCH_LIBNAME)_isp -l$(ARCH_LIBNAME)_vi \
							-l$(ARCH_LIBNAME)_vo -lhifb -l$(ARCH_LIBNAME)_vpss -l$(ARCH_LIBNAME)_vgs -ltde -l$(ARCH_LIBNAME)_tde -lhi_mipi_rx\
							-l$(ARCH_LIBNAME)_chnl -l$(ARCH_LIBNAME)_rc -l$(ARCH_LIBNAME)_rgn -l$(ARCH_LIBNAME)_vedu \
							-l$(ARCH_LIBNAME)_venc -l$(ARCH_LIBNAME)_h265e -l$(ARCH_LIBNAME)_jpege -l$(ARCH_LIBNAME)_h264e  \
							-lhi_cipher\
							-l_hidehaze -l_hidrc -l_hildci -l_hiawb -l_hiae -lisp  -lhi_sensor_i2c \
							-lupvqe -ldnvqe -lVoiceEngine -l$(ARCH_LIBNAME)_ai -l$(ARCH_LIBNAME)_ao -l$(ARCH_LIBNAME)_aio -l$(ARCH_LIBNAME)_aenc -l$(ARCH_LIBNAME)_adec -l$(ARCH_LIBNAME)_acodec \
							-laaccomm -laacenc -laacdec -laacsbrenc -laacsbrdec\
							-lhive_RES -lhive_record -lhive_HPF -lhive_AEC -lhive_AGC -lhive_ANR -lhive_EQ\
							-lbcd\
							-lhi_sensor_spi -lhi_pwm -lhi_piris -lhi_sil9024 -lhi_ssp_ota5182\
							-lhi_ssp_st7789 \
							-l$(ARCH_LIBNAME)_ive -live -lmd -livp\
							--end-group
							# -l$(ARCH_LIBNAME)_ive -live

SDK_LIB += $(SENSOR_LIBS)

LITEOS_LIBDEPS = --start-group $(LITEOS_LIBDEP) --end-group $(LITEOS_TABLES_LDFLAGS)

LDFLAGS := $(LITEOS_LDFLAGS) --gc-sections

# target source
SRCS  += $(SAMPLE_DIR)/$(OSTYPE)/app_init.c
SRCS  += $(REL_DIR)/init/sdk_init.c
#SRCS  += $(REL_DIR)/init/sdk_exit.c
OBJS  := $(SRCS:%.c=%.o)
OBJS += $(COMM_OBJ)

CFLAGS += $(COMM_INC)
CFLAGS += -I$(OSAL_ROOT)/include

BIN := $(TARGET_PATH)/$(TARGET).bin
MAP := $(TARGET_PATH)/$(TARGET).map

.PHONY : clean all

all: $(BIN)

$(BIN):$(TARGET)
	@$(OBJCOPY) -O binary $(TARGET_PATH)/$(TARGET) $(BIN)

$(TARGET):$(OBJS)
	$(LD) $(LDFLAGS) -Map=$(MAP) -o $(TARGET_PATH)/$(TARGET) $(OBJS) $(SDK_LIB) $(LITEOS_LIBDEPS) $(REL_LIB)/libsecurec.a
	@$(OBJDUMP) -d $(TARGET_PATH)/$(TARGET) > $(TARGET_PATH)/$(TARGET).asm

$(OBJS):%.o:%.c
	$(CC) $(CFLAGS) -c $< -o $@

clean:
	@rm -f $(TARGET_PATH)/$(TARGET) $(BIN) $(MAP) $(TARGET_PATH)/*.asm
	@rm -f $(OBJS)
